﻿{% extends "base.html" %}

{% block breadcrumb %}
    {{ block.super }}
    {% load breadcrumb_tags %}
    {% add_crumb 'Báo cáo' 'department_report' %}
    {% add_crumb 'Hạnh kiểm theo khối'  %}
	
{% endblock %}

{% block js  %}
	<script>
        $(document).ready(function () {
			$("#year").change(function(){
				//alert("chao");
				$("#term").val("-1");
			})
            $('#term').change(function () {
                var year = $('#year').val().split("-")[0];
                var term = $('#term').val();
                if (term != '-1' )
                    window.location.href = "/school/report/practisingByGrade/" + year +"/"+term;
            })
			var nextYear = {{yearNumber}}+1;
			var yearString="{{yearNumber}}-"+nextYear; 
			$("#year").val(yearString);
			$("#term").val("{{termNumber}}");
		});
	</script>
{% endblock %}

{% block content %}
    <div class="btn-toolbar form-inline pagination-centered">
		Năm học
		<select id="year" style="width:100px">
			{% for i in yearList %}
				<option value={{i}}> {{i}} </option>
			{% endfor %}	
		</select>
		Học kỳ
        <select id="term" style="width:100px">
			<option value='-1'> ----------- </option>
			<option value='1'> Học kỳ I </option>
			<option value='2'> Học kỳ II  </option>
			<option value='3'> Cả năm  </option>
		</select>	
        <a class='btn' href="{%url practising_by_grade yearNumber termNumber 1 %}">Xuất ra Excel </a>
    </div>
	<table class="table grid">
	<thead><tr>
		<th rowspan="2">
			Khối
		</th>
		<th rowspan="2">
			TS
		</th>
		<th colspan="2" >
			Tốt
		</th>
		<th colspan="2" >
			Khá
		</th>
		<th colspan="2">
			Trung bình
		</th>
		<th colspan="2">
			Yếu
		</th>
	</tr>
	<tr>
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
        <th>SL</th>
        <th>%</th>
	</tr>
	</thead>

	<tbody>	
	{% for subList in list %}
		{% if forloop.counter > 5 %}
			<tr>
				<td>
					{{forloop.counter}}
				</td>
			{% for sl in subList %}
				{% if forloop.counter|divisibleby:"2" or forloop.counter == 1 %} 	
					<td>
						{{ sl}}
					</td>
				{% else %}	
					<td>
						{{ sl|floatformat:"2" }}
					</td>
				{% endif %}	
			{% endfor %}
			</tr>
		{% endif %}	
	{% endfor %}
	</tbody>
	</table>
	
{% endblock %}
